{% import "TopxiaWebBundle::macro.html.twig" as web_macro %}
<!-- course -->
<div class="es-box es-course">
  <h2>{{ config.title|default(config.defaultTitle) }}</h2>
  {% set count = config.count %}
  {% set categoryId = config.categoryId|default(null) %}
  {% set courses = data('LatestCourses',{'count':count, 'categoryId':categoryId}) %}
  {% if courses %}
  {% set mode = mode|default('default') %}
    <ul class="row">
      {% for course in courses %}
        <li class="col-sm-6 col-md-4 es-course-list">
          <div>
            <div class="course-top">
                  <img src="{{ file_path(course.largePicture, 'course-large.png') }}"  class="img-responsive thumb">
            </div>
            <div class="course-bottom">
                  <h3>{{ course.title }}</h3>
                  <p class="metas clearfix">
                      {% if course.price > 0 %}
                        <span class="price-num">¥{{ course.price }}</span>
                      {% else %}
                        <span class="price-num">免费</span>
                      {% endif %}
                  

                    {% if course.showStudentNumType == 'opened' %}
                      <span class="student-num">{{ course.studentNum }}人报名</span>
                    {% endif %}
                 </p>

                    <span class="nickname">
                      {% for teacher in course.teachers %}
                        {{ web_macro.user_link(teacher, 'text-muted') }}
                      {% endfor %}
                    </span>
            </div>

             <div class="mask">
              <a href="{{ path('course_show', {id:course.id}) }}">
                  {% set teacher = course.teachers|first %}
                  <div class="teacher-info clearfix">
                    <img class="img-circle pull-left" src="{{ file_path(teacher.smallAvatar, 'avatar.png') }}">
                    <span>{{ teacher.nickname }}</span>
                    <span>{{ teacher.title|plain_text(10) }}</span>
                  </div>
                  <p>{{ teacher.profile.about|plain_text(50) }}</p>
                  <span class="iconfont icon-jiantou"></span>
                  <h3 class="title">{{ course.title|plain_text(8) }}</h3>
              </a>
            </div>

          </div>
        </li>
      {% endfor %}
    </ul>


  {% else %}
      <div class="empty">还没有发布的课程</div>
  {% endif %}
  <a class="more" href="{{ path('course_explore',{category:config.categoryId|default(null)}) }}">更多&gt;</a>

</div>